package com.hwd.srb.core.enmu;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Arrays;

/**
 * @author 黄伟东/Victor
 * @date 2022/3/21 21:30
 * @Description 性别枚举类
 */
@NoArgsConstructor
@AllArgsConstructor
@Getter
public enum SexEnum {

    FEMALE(0, "女"),
    MALE(1, "男"),
    ;

    @EnumValue
    private Integer sex;

    @JsonValue
    private String msg;

    @Override
    public String toString() {
        return this.msg;
    }

    public static String getMsgByUserType(int sex) {
        return Arrays.stream(SexEnum.values())
                .filter(obj -> sex == obj.getSex())
                .findFirst()
                .map(SexEnum::getMsg)
                .orElse("");
    }
}
